<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form ref="filterForm" :model="filterForm" :inline="true" label-position="left" label-width="100px">
        <el-form-item label="关键字" prop="keyword">
          <el-input v-model="filterForm.keyword" clearable placeholder="项目ID/项目标题/项目内容" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
        </el-form-item>
        <el-form-item label="状态" prop="status">
            <el-radio-group v-model="filterForm.status">
              <el-radio-button label="-1">全部</el-radio-button>
              <el-radio-button label="1">成功</el-radio-button>
              <el-radio-button label="0">失败</el-radio-button>
            </el-radio-group>
        </el-form-item>
      </el-form>
      <el-button @click="handleFilter">刷新</el-button>
      <div>
        <div>存款：{{statisticsData.depositAmount}}</div>
        <div>取款:{{statisticsData.withdrawAmount}}</div>
        <div>小计:{{statisticsData.profitAmount}}</div>
      </div>
    </div>
    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%;"
      @sort-change="sortChange"
    >
      <el-table-column label="流水号" prop="id" sortable="custom" align="center">
        <template slot-scope="{row}">
          <span>{{ row.PlateSerial }}</span>
        </template>
      </el-table-column>
      <el-table-column label="账号" prop="id" sortable="custom" align="center">
        <template slot-scope="{row}">
          <span>{{ row.AccountID }}</span>
        </template>
      </el-table-column>
      <el-table-column label="转账时间" min-width="150px">
        <template slot-scope="{row}">
          <div>{{ row.TradingDay }} {{ row.TradeTime }}</div>
        </template>
      </el-table-column>
      <el-table-column label="金额" min-width="150px">
        <template slot-scope="{row}">
          <div>{{ row.TradeAmount }}<el-tag v-if="row.TradeCode == 202002" type="danger">转出</el-tag><el-tag v-else>转入</el-tag></div>
        </template>
      </el-table-column>
      <el-table-column label="备注" min-width="150px">
        <template slot-scope="{row}">
          <div>{{ row.ErrorMsg }}</div>
        </template>
      </el-table-column>
      <el-table-column label="记录时间" min-width="150px">
        <template slot-scope="{row}">
          <div>{{ row.createdAt }}</div>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="filterForm.page" :limit.sync="filterForm.size" @pagination="getList" />
  </div>
</template>

<script>
import { getFundList } from '@/api/chinactp/fund'
import waves from '@/directive/waves' // waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

export default {
  name: 'faultinessAdmin',
  components: { Pagination },
  directives: { waves },
  filters: {
  },
  data() {
    return {
      socket:"",
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: false,
      connected:"loading",
      depositForm:{
        amount:100
      },
      hiddenDepositWrapper:false,
      statisticsData:{
        depositAmount:0,
        withdrawAmount:0
      },
      filterForm: {
        page: 1,
        size: 10,
        simulation: 2,
        status: '-1'
      }
    }
  },
  created() {
    this.getList()
  },
  
  methods: {
    handleDepositSubmit:function(){
      this.send({
        "conversationType":"finance.deposit.save",
        "message":this.depositForm,
        "target":{"id":"3"}
      })
    },
    getList:function(){
      let _this = this;
      console.log(_this.filterForm)
      getFundList(_this.filterForm).then((response) => {
        console.log(response)
          if (response.code === 200) {
            this.list = response.data.list
            this.total = response.data.total
            this.statisticsData = response.data.statistics
          } else {
            _this.$message({
              message: response.msg,
              type: 'error'
            })
          }
      })
    },
    handleFilter() {
      this.filterForm.page = 1
      this.getList()
    },
    sortChange(data) {
      const { prop, order } = data
      if (prop === 'id') {
        this.sortByID(order)
      }
    },
    sortByID(order) {
      if (order === 'ascending') {
        this.filterForm.sort = '+id'
      } else {
        this.filterForm.sort = '-id'
      }
      this.handleFilter()
    }
  }
}
</script>
<style>

</style>